/**
 * Copyright 2009 Henning Teek, Ingo Renner
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.googlecode.bricket.web.common.wizard;

import com.googlecode.bricket.web.common.forms.ShinyForm;

import org.apache.wicket.Component;
import org.apache.wicket.extensions.wizard.Wizard;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.FeedbackPanel;

public class DefaultWizard extends Wizard {
	final boolean editable;
	
	public boolean isEditable() {
		return editable;
	}

	public DefaultWizard(String id) {
		this(id, true);
	}

	public DefaultWizard(String id, boolean editable) {
		super(id);
		this.editable = editable;
	}

	@Override
	public void onCancel() {
		setResponsePage(getPage().getClass());
	}
	
	@Override
	protected Component newButtonBar(String id) {
		return new DefaultWizardButtonBar(id, this, editable);
	}

	@Override
	protected FeedbackPanel newFeedbackPanel(String id) {
		return (FeedbackPanel) new FeedbackPanel(id).setVisible(false);
	}
	
	@Override
	protected <E> Form<E> newForm(String id) {
		return new ShinyForm<E>(id);
	}
}

